

#if defined(TSINGMA)

#include "ctc_error.h"
#include "sys_usw_mchip.h"
#include "sys_usw_ipuc.h"
#include "sys_tsingma_ipuc_tcam.h"
#include "sys_tsingma_nalpm.h"
#include "sys_tsingma_mac.h"
#include "sys_tsingma_datapath.h"
#include "sys_tsingma_mcu.h"
#include "sys_usw_ftm.h"
#include "sys_tsingma_peri.h"
#include "sys_usw_parser.h"
#include "sys_usw_linkagg.h"
#include "sys_tsingma_port.h"
#include "sys_tsingma_dot1ae.h"
extern int32 sys_tsingma_capability_init(uint8 lchip);
extern int32 sys_tsingma_hash_set_config(uint8 lchip, void* p_hash_cfg);
extern int32 sys_tsingma_hash_get_config(uint8 lchip, void* p_hash_cfg);
extern int32 sys_tsingma_hash_set_offset(uint8 lchip, void* p_hash_offset);
extern int32 sys_tsingma_hash_get_offset(uint8 lchip, void* p_hash_offset);
extern int32 sys_tsingma_hash_set_hash_control(uint8 lchip, void* p_hash_ctl);
extern int32 sys_tsingma_hash_get_hash_control(uint8 lchip, void* p_hash_ctl);
extern int32 sys_tsingma_hash_set_packet_disable(uint8 lchip, uint8 sel_id, uint8 packet_type, uint8 disable);
extern int32 sys_tsingma_interrupt_set_sup_op(uint8 lchip, uint8 grp_id, uint8 act_idx);

extern int32
sys_usw_qos_api_cb_register_before_at(uint8 lchip, void** api_cb);

extern int32
sys_tsingma_parser_set_global_cfg(uint8 lchip, ctc_parser_global_cfg_t* p_global_cfg);
extern int32
sys_tsingma_parser_get_global_cfg(uint8 lchip, ctc_parser_global_cfg_t* p_global_cfg);
extern int32
sys_tsingma_parser_set_hash_field(uint8 lchip,
                                  void* p_hash_ctl,
                                  uint8 hash_usage);
extern int32
sys_tsingma_parser_get_hash_field(uint8 lchip,
                                  void* p_hash_ctl,
                                  uint8 hash_usage);


extern int32
sys_tsingma_parser_hash_init(uint8 lchip);

extern int32
sys_tsingma_nalpm_show_sram_usage(uint8 lchip);

/**DIAG START*/
extern int32
sys_tsingma_diag_get_pkt_trace(uint8 lchip, void* p_value, uint8 position);
extern int32
sys_tsingma_diag_get_drop_info(uint8 lchip, void* p_value);
extern int32
sys_tsingma_diag_set_dbg_pkt(uint8 lchip, void* p_value);
extern int32
sys_tsingma_diag_set_dbg_session(uint8 lchip, void* p_value);
extern int32
sys_tsingma_diag_get_lb_hash(uint8 lchip, ctc_field_key_t* p_field_list, uint32 field_cnt, ctc_diag_lb_hash_t* p_rslt);
extern char*
sys_tm_get_discard_type_desc(uint16 discard_type);
extern int32
sys_tsingma_diag_get_pos(uint16 discard, uint8* pos);
extern int32
sys_tm_map_drop_reason_ctc_to_sys(uint16 drop_reason, uint32* discard_type_bmp);
extern int32
sys_tm_diag_get_drop_reason(uint8 lchip, uint32* reason);

/**DIAG END*/
extern int32
sys_tsingma_mac_link_up_event(uint8 lchip, uint16 lport);
extern int32
sys_tsingma_mac_link_down_event(uint8 lchip, uint16 lport);

extern int32
sys_tsingma_mac_set_capability(uint8 lchip, uint16 lport, ctc_port_capability_type_t type, uint32 value);

extern int32
sys_tsingma_nalpm_show_sram_usage(uint8 lchip);

extern int32
_sys_usw_scl_build_hash_key_2vlan_port(uint8 lchip, ctc_field_key_t* pKey, void* pe, uint8 is_add);
extern int32
_sys_usw_scl_build_field_action_igs_vlan_edit(uint8 lchip, void* ds, void* pe, ctc_scl_field_action_t* pAction, uint8 is_add);
extern int32
_sys_usw_scl_build_field_action_igs(uint8 lchip, ctc_scl_field_action_t* pAction, void* pe, uint8 is_add);
extern int32
_sys_usw_scl_build_field_action_flow(uint8 lchip, ctc_scl_field_action_t* pAction, void* pe, uint8 is_add);
extern int32
_sys_usw_scl_get_field_action_igs(uint8 lchip, ctc_scl_field_action_t* p_action, void* pe);
extern int32
_sys_usw_scl_get_field_action_flow(uint8 lchip, ctc_scl_field_action_t* pAction, void* pe);
extern int32
_sys_usw_scl_update_action(uint8 lchip, void* data, void* change_nh_param);

extern int32
_sys_usw_flow_stats_type_init(uint8 lchip);
extern int32
_sys_usw_flow_stats_ram_init(uint8 lchip);
extern int32
sys_duet2_flow_stats_show_status(uint8 lchip);
extern int32
sys_tsingma_flow_stats_ds2count(uint8 lchip, uint32 tbl_id, void* p_ds, ctc_stats_basic_t* p_count);

extern int32
sys_tm_map_drop_reason_sys_to_ctc(uint16 discard_type, uint16 * p_drop_reason);
extern int32
sys_duet2_wb_app_id_init(uint8 lchip, void* p_app_id_info);
extern int32
sys_tm_get_drop_resson_info(uint16 discard_type, uint8* p_dir, uint8* p_clear_on_read);

extern int32
sys_tsingma_interrupt_get_intrvec_offset(uint8 lchip, uint32 intr_type, uint32 * p_offset);
extern int32
sys_tsingma_interrupt_get_sup_info(uint8 lchip, uint32 intr_type, uint32 *p_sup_table_id, uint16 *p_bit_offset, uint32 *p_func_table_id);
extern int32
sys_tsingma_interrupt_db_init(uint8 lchip);
extern int32
sys_tsingma_interrupt_isr_sup_normal(uint8 lchip, uint32 intr, void* p_data);
extern int32
sys_tsingma_interrupt_init_reg(uint8 lchip);

extern int32
sys_usw_register_add_compress_ether_type(uint8 lchip, uint16 new_ether_type, uint16 old_ether_type,uint8* o_cether_type, uint8* o_cether_type_index);
extern int32
sys_usw_register_remove_compress_ether_type(uint8 lchip, uint8 ether_type_index);
extern int32
sys_tsingma_nalpm_wb_prefix_restore(uint8 lchip);
extern int32
sys_tsingma_nalpm_wb_prefix_sync(uint8 lchip, uint32 app_id, void* p_wb_data);
extern int32
sys_tsingma_packet_txinfo_to_rawhdr(uint8 lchip, ctc_pkt_tx_t* p_pkt_tx);
extern int32
sys_tsingma_packet_rawhdr_to_rxinfo(uint8 lchip, uint32* p_raw_hdr_net, ctc_pkt_rx_t* p_pkt_rx);
extern int32
sys_tsingma_packet_encap_array(uint8 lchip, ctc_pkt_tx_t** p_pkt_tx_array, uint32 count);

extern void _sys_usw_acl_show_kset(uint8 lchip, ctc_acl_flex_key_t * acl_flex_key);
extern int32
_sys_usw_acl_get_flex_key_fields(uint8 lchip, ctc_acl_flex_key_t * acl_flex_key);
extern int32
sys_dute2_oam_get_mep_info_for_event(uint8 lchip, void* p_mep_info);
extern int32
_sys_usw_ipfix_decode_hashkey_ad(uint8 lchip, void* p_data, uint8 is_ad, void* p_key);
extern int32
sys_usw_ipfix_cb_init(uint8 lchip);
extern int32
sys_dute2_aging_get_key_index(uint8 lchip, uint32 aging_ptr, uint8* domain_type, uint32* key_index);
extern int32
sys_duet2_aging_get_aging_ptr(uint8 lchip, uint8 domain_type, uint32 key_index, uint32* aging_ptr);
extern int32
sys_duet2_aging_set_aging_status(uint8 lchip, uint8 domain_type, uint32 key_index, uint8 timer, uint8 status);
extern int32
sys_tsingma_monitor_sync_data(uint8 lchip, void* p_data);
extern int32 sys_tsingma_interrpt_dispatch_func(uint8 lchip, uint32* p_status);
extern int32 sys_tsingma_datapath_get_extport_start_id(uint8 lchip, uint16* p_lport_start);
extern int32
sys_tsingma_mac_set_direction_property(uint8 lchip, uint16 lport, ctc_port_direction_property_t port_prop, ctc_direction_t dir, uint32 value);
extern int32
sys_tsingma_mac_get_direction_property(uint8 lchip, uint16 lport, ctc_port_direction_property_t port_prop, ctc_direction_t dir, uint32* p_value);
extern int32
sys_duet2_register_get_glb_acl_table(uint8 lchip, uint8 dir, void* p_glb_acl_lkup);
extern int32
sys_tsingma_mac_get_link_info(uint8 lchip, uint16 lport, void* p_value);
extern int32
sys_tsingma_mac_set_link_info(uint8 lchip, uint16 lport, void* p_value);
extern int32
_sys_tsingma_check_datapath_credit_clear(uint8 lchip, uint32 mac_id, uint32 chan_id);
extern int32
sys_duet2_dot1ae_set_global_cfg(uint8 lchip, void* glb_cfg);
extern int32
sys_duet2_dot1ae_chan_wb_restore(uint8 lchip, void* sys_chan);
extern int32
sys_duet2_dot1ae_get_global_cfg(uint8 lchip, void* glb_cfg);

extern int32
sys_duet2_dot1ae_build_sc_index(uint8 lchip, void* sys_chan);

extern int32
sys_duet2_dot1ae_free_sc_index(uint8 lchip, void* sys_chan);

extern int32
sys_duet2_dot1ae_reset_sec_chan_cfg(uint8 lchip, void* sys_chan);

extern int32
sys_tsingma_dot1ae_add_sc_to_asic(uint8 lchip, void* sys_chan);

extern int32
sys_tsingma_dot1ae_add_sa_to_asic(uint8 lchip, void* sys_chan, uint8 sa_idx, uint32 update_flag);

extern int32
sys_tsingma_dot1ae_register_init(uint8 lchip);

extern int32
sys_tsingma_dot1ae_update_sec_chan(uint8 lchip, void* sys_chan, void* sc);

extern int32
sys_tsingma_dot1ae_get_stats(uint8 lchip, uint32 chan_id, void* stats);

extern int32
sys_tsingma_dot1ae_sync_dma_stats(uint8 lchip, void* p_data);

extern int32
sys_duet2_dot1ae_unbind_sec_chan(uint8 lchip, void* bind_sc);

/* dmps_db */
extern int32 sys_usw_dmps_get_port_property(uint8 lchip, sys_dmps_port_info_t* port_info, uint8 dmps_port_prop, void *p_value);
extern uint16 sys_usw_dmps_get_lport_with_chan(uint8 lchip, uint8 dir_bmp, uint16 chan_id);
extern uint16 sys_usw_dmps_get_lport_with_subchan(uint8 lchip, uint8 sub_chan_id);
extern uint16 sys_usw_dmps_get_lport_with_subchan_db(uint8 lchip, uint8 dir_bmp, uint8 core, uint8 pp, uint8 dp, uint8 sub_chan_id);
extern uint16 sys_usw_dmps_get_lport_with_mac(uint8 lchip, uint16 mac_id);
extern int32 sys_dmps_get_sub_chan_by_chan(uint8 lchip, uint8 dir_bmp, uint16 chan, uint16* sub_chan, uint8* pp_id, uint8* dp_id);

/*peri*/
extern int32 sys_tsingma_peri_get_gpio_input(uint8 lchip, uint8 gpio_id, uint8* in_value);
extern int32 sys_tsingma_peri_get_mac_led_en(uint8 lchip, bool* enable);
extern int32 sys_tsingma_peri_set_mac_led_clock(uint8 lchip, uint16 freq);
extern int32 sys_tsingma_peri_get_mac_led_clock(uint8 lchip, uint16 * freq);
extern int32 sys_tsingma_peri_get_mdio_clock(uint8 lchip, ctc_chip_mdio_type_t type, uint16* freq);
extern int32 sys_tsingma_peri_get_phy_scan_para(uint8 lchip, ctc_chip_phy_scan_ctrl_t* p_scan_para);
extern int32 sys_tsingma_peri_init(uint8 lchip);
extern int32 sys_tsingma_peri_mdio_init(uint8 lchip);
extern int32 sys_tsingma_peri_phy_link_change_isr(uint8 lchip, uint32 intr, void* p_data);
extern int32 sys_tsingma_peri_get_chip_sensor(uint8 lchip, void* sensor);
extern int32 sys_tsingma_peri_set_phy_sample_offset(uint8 lchip, ctc_chip_mdio_para_t* p_mdio_para);
extern int32 sys_tsingma_peri_get_phy_sample_offset(uint8 lchip, ctc_chip_mdio_para_t* p_mdio_para);
extern int32 sys_tsingma_peri_set_phy_sample_edge(uint8 lchip, ctc_chip_mdio_para_t* p_mdio_para);
extern int32 sys_tsingma_peri_get_phy_sample_edge(uint8 lchip, ctc_chip_mdio_para_t* p_mdio_para);
extern int32 sys_tsingma_peri_read_phy_reg(uint8 lchip, ctc_chip_mdio_type_t type, ctc_chip_mdio_para_t* p_para);
extern int32 sys_tsingma_peri_set_gpio_mode(uint8 lchip, uint8 gpio_id, ctc_chip_gpio_mode_t mode);
extern int32 sys_tsingma_peri_set_gpio_output(uint8 lchip, uint8 gpio_id, uint8 out_para);
extern int32 sys_tsingma_peri_set_mac_led_en(uint8 lchip, bool enable);
extern int32 sys_tsingma_peri_set_mac_led_mapping(uint8 lchip, ctc_chip_mac_led_mapping_t* p_led_map);
extern int32 sys_tsingma_peri_set_mac_led_mode(uint8 lchip, ctc_chip_led_para_t* p_led_para, ctc_chip_mac_led_type_t led_type, uint8 inner);
extern int32 sys_tsingma_peri_set_mdio_clock(uint8 lchip, ctc_chip_mdio_type_t type, uint16 freq);
extern int32 sys_tsingma_peri_set_phy_scan_cfg(uint8 lchip);
extern int32 sys_tsingma_peri_set_phy_scan_para(uint8 lchip, ctc_chip_phy_scan_ctrl_t* p_scan_para);
extern int32 sys_tsingma_peri_write_phy_reg(uint8 lchip, ctc_chip_mdio_type_t type, ctc_chip_mdio_para_t* p_para);

/*dma*/
extern int32
sys_tsingma_dma_tcam_scan_func(uint8 lchip, uint16 chan);
extern int32
sys_duet2_dma_set_tcam_scan_mode(uint8 lchip, uint8 mode, uint32 timer);
extern int32
sys_tsingma_dma_sync_pkt_rx_stats(uint8 lchip);
extern int32
sys_tsingma_dma_sync_pkt_tx_stats(uint8 lchip);
extern int32
sys_tsingma_dma_pkt_tx(uint8 lchip, ctc_pkt_tx_t* p_pkt_tx);
extern int32
sys_tsingma_dma_pkt_rx(uint8 lchip, uint8 chan_id, void* p_thread_info);
extern int32
sys_tsingma_dma_set_pkt_timer(uint8 lchip, uint32 timer, uint8 enable);
extern int32
sys_tsingma_dma_set_session_pkt(uint8 lchip, uint16 session_id, ctc_pkt_tx_t* p_pkt);
extern int32
sys_duet2_dma_function_pause(uint8 lchip, uint8 chan_id, uint8 en);
extern int32
sys_tsingma_dma_sync_hash_dump(uint8 lchip, void* p_pa, uint16* p_entry_num, void* p_data);
extern int32
sys_tsingma_dma_set_packet_timer_cfg(uint8 lchip, uint16 max_session, uint16 interval, uint16 pkt_len, uint8 is_destroy);
extern int32
sys_tsingma_dma_info_func(uint8 lchip, uint8 chan);
extern int32
sys_tsingma_dma_stats_func(uint8 lchip, uint8 chan);
extern int32
sys_tsingma_dma_pkt_tx_array(uint8 lchip, ctc_pkt_tx_t** p_pkt_tx_array, uint32 count);
extern int32
sys_tsingma_dma_read_table(uint8 lchip, void* tbl_cfg);
extern int32
sys_tsingma_dma_write_table(uint8 lchip, void* tbl_cfg);
extern int32
sys_tsingma_dma_reset(uint8 lchip);

extern int32
sys_duet2_l3if_set_igs_if_rmac(uint8 lchip, uint16 l3if_id, ctc_l3if_router_mac_t router_mac);
extern int32
sys_duet2_l3if_get_igs_if_rmac(uint8 lchip, uint16 l3if_id, ctc_l3if_router_mac_t* router_mac);

extern int32
sys_usw_linkagg_dlb_set_config(uint8 lchip, void* p_cfg);
extern int32
sys_usw_linkagg_dlb_get_config(uint8 lchip, void* p_cfg);
extern int32
_sys_usw_nh_ecmp_clear_dlb_flow(uint8 lchip, void* p_nhdb_param);
extern int32
_sys_usw_mac_get_cl37_en(uint8 lchip, uint16 lport, uint32* p_value);
extern int32
_sys_usw_mac_get_cl37_mode(uint8 lchip, uint16 lport, uint32* p_value);
extern int32
sys_tsingma_mac_get_sfd_en(uint8 lchip, uint16 lport, uint32* enable);
extern int32
sys_tsingma_mac_set_sfd_en(uint8 lchip, uint16 lport, uint32 enable);
extern int32
_sys_usw_mac_set_port_cl73_ability(uint8 lchip, uint16 lport, void* p_ability);

sys_usw_mchip_1ae_t sys_tsingma_mchip_1ae =
{
#if (FEATURE_MODE == 0)
    sys_tsingma_dot1ae_add_sc_to_asic,
    sys_tsingma_dot1ae_add_sa_to_asic,
    sys_duet2_dot1ae_build_sc_index,
    sys_duet2_dot1ae_free_sc_index,
    sys_duet2_dot1ae_reset_sec_chan_cfg,
    NULL, /* get_en_sec_chan*/
    NULL, /* en_sec_chan*/
    sys_tsingma_dot1ae_update_sec_chan,
    sys_duet2_dot1ae_unbind_sec_chan,
    sys_duet2_dot1ae_set_global_cfg,
    sys_duet2_dot1ae_get_global_cfg,
    sys_tsingma_dot1ae_get_stats,
    sys_tsingma_dot1ae_sync_dma_stats,
    sys_tsingma_dot1ae_register_init,
    NULL, /* add_entry*/
    NULL, /* remove_entry*/
    NULL, /* show_entry*/
    NULL, /* chk_pp_id */
    NULL, /* set_hash_field_sel */
    NULL, /* get_hash_field_sel */
    NULL, /* set_chan_ctl */
    sys_duet2_dot1ae_chan_wb_restore,
    NULL,   /* entry_hash_init */
    NULL    /* entry_hash_deinit */
#endif
};

sys_usw_mchip_lag_t sys_tsingma_mchip_lag =
{
    NULL,   // destroy
    NULL,   // add_nonuc_ports
    NULL,   // remove_nonuc_ports
    NULL,   // dlb_init
    sys_usw_linkagg_dlb_set_config,
    sys_usw_linkagg_dlb_get_config,
    NULL,   // set_lsh
    NULL,   // channel_update_nonuc_ports
    NULL,   // bind_mirror
    NULL,   // replace_nonuc_ports
    NULL,   // update_nonuc_ports_by_pp
    NULL    // loop_chan_lag_en
};

sys_usw_mchip_dmps_t sys_tsingma_mchip_dmps =
{
    .mac_set_property                   = sys_tsingma_mac_set_property,
    .mac_get_property                   = sys_tsingma_mac_get_property,
    .mac_set_interface_mode             = sys_tsingma_mac_set_interface_mode,
    .mac_get_link_up                    = sys_tsingma_mac_get_link_up,
    .mac_get_capability                 = sys_tsingma_mac_get_capability,
    .mac_set_capability                 = sys_tsingma_mac_set_capability,
    .serdes_set_property                = sys_tsingma_serdes_set_property,
    .serdes_get_property                = sys_tsingma_serdes_get_property,
    .serdes_set_mode                    = sys_tsingma_serdes_set_mode,
    .serdes_set_link_training_en        = sys_tsingma_serdes_set_link_training_en,
    .serdes_get_link_training_status    = sys_tsingma_serdes_get_link_training_status,
    .datapath_init                      = sys_tsingma_datapath_init,
    .mac_init                           = sys_tsingma_mac_init,
    .mcu_show_debug_info                = sys_tsingma_mcu_show_debug_info,
    .mac_self_checking                  = sys_tsingma_mac_self_checking,
    .mac_link_up_event                  = sys_tsingma_mac_link_up_event,
    .mac_link_down_event                = sys_tsingma_mac_link_down_event,
    .datapath_get_extport_start_id      = sys_tsingma_datapath_get_extport_start_id,
    .mac_set_direction_property         = sys_tsingma_mac_set_direction_property,
    .mac_get_direction_property         = sys_tsingma_mac_get_direction_property,
    .mac_set_link_info                  = sys_tsingma_mac_set_link_info,
    .mac_get_link_info                  = sys_tsingma_mac_get_link_info,
    .check_datapath_credit_clear        = _sys_tsingma_check_datapath_credit_clear,
    .mac_get_sfd_en                     = sys_tsingma_mac_get_sfd_en,
    .mac_set_sfd_en                     = sys_tsingma_mac_set_sfd_en,
    .mac_get_cl37_en                    = _sys_usw_mac_get_cl37_en,
    .mac_get_cl37_mode                  = _sys_usw_mac_get_cl37_mode,
    .mac_set_port_cl73_ability          = _sys_usw_mac_set_port_cl73_ability,
};

sys_usw_mchip_flexe_t sys_tsingma_mchip_flexe =
{
    /*flexe dmps API >> , need register by Qicx*/
    NULL,
    NULL,
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    NULL,  /**/
    /*flexe dmps API <<*/
};
sys_usw_mchip_ipuc_t sys_tsingma_mchip_ipuc =
{
#if ((FEATURE_MODE == 2) || (FEATURE_MODE == 0))
    sys_tsingma_ipuc_tcam_init,
    sys_tsingma_ipuc_tcam_deinit,
    sys_tsingma_ipuc_tcam_get_blockid,
    sys_tsingma_ipuc_tcam_write_key,
    sys_tsingma_ipuc_tcam_write_ad,
    sys_tsingma_ipuc_tcam_move,
    sys_tsingma_ipuc_tcam_show_key,
    sys_tsingma_ipuc_tcam_show_status,
    sys_tsingma_nalpm_show_sram_usage,
    sys_tsingma_nalpm_init,
    sys_tsingma_nalpm_deinit,
    sys_tsingma_nalpm_add,
    sys_tsingma_nalpm_del,
    sys_tsingma_nalpm_update,
    NULL,
    sys_tsingma_nalpm_show_route_info,
    sys_tsingma_nalpm_show_status,
    NULL,
    sys_tsingma_nalpm_wb_get_info,
    sys_tsingma_nalpm_dump_db,
    sys_tsingma_nalpm_merge,
    sys_tsingma_nalpm_set_fragment_status,
    sys_tsingma_nalpm_get_fragment_status,
    sys_tsingma_nalpm_get_fragment_auto_enable,
    NULL,
    sys_tsingma_nalpm_check_route,
    NULL,
    sys_tsingma_nalpm_wb_prefix_restore,
    sys_tsingma_nalpm_wb_prefix_sync,
    sys_tsingma_ipuc_alloc_tcam_key_index,
    sys_tsingma_ipuc_free_tcam_key_index,
    sys_tsingma_ipuc_tcam_move_cb,
    sys_duet2_ipuc_build_ipda_nexthop,
    sys_duet2_ipuc_write_ipda,
    sys_tsingma_nalpm_wb_set_tcam_index,
    sys_tsingma_nalpm_wb_set_ad_info,
    /* nalpm */
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
#endif
};
sys_usw_mchip_acl_t sys_tsingma_mchip_acl =
{
    NULL,
    NULL,
    NULL,
    _sys_usw_acl_get_flex_key_fields,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    _sys_usw_acl_show_kset,
    NULL,
    NULL,
    NULL,
    NULL
};

sys_usw_mchip_scl_t sys_tsingma_mchip_scl =
{
    _sys_usw_scl_build_hash_key_2vlan_port,
    _sys_usw_scl_build_field_action_igs_vlan_edit,
    _sys_usw_scl_build_field_action_igs,
    _sys_usw_scl_build_field_action_flow,
    _sys_usw_scl_get_field_action_igs,
    _sys_usw_scl_get_field_action_flow,
    _sys_usw_scl_update_action,
    NULL,
    sys_usw_register_add_compress_ether_type,
    sys_usw_register_remove_compress_ether_type,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
};

sys_usw_mchip_l3if_t sys_tsingma_mchip_l3if =
{
    sys_duet2_l3if_set_igs_if_rmac,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    sys_duet2_l3if_get_igs_if_rmac
};

sys_usw_mchip_ipfix_t sys_tsingma_mchip_ipfix =
{
#if (FEATURE_MODE == 0)
    _sys_usw_ipfix_decode_hashkey_ad,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    sys_usw_ipfix_cb_init,
    NULL,/*ipfix_set_flex_key*/
    NULL,/*ipfix_get_flex_key*/
    NULL,/*ipfix_get_flex_key_sets*/
    NULL/*ipfix_encode_xkey_hash*/
#endif
};

sys_usw_mchip_aging_t sys_tsingma_mchip_ag =
{
    NULL,
    sys_dute2_aging_get_key_index,
    sys_duet2_aging_get_aging_ptr,
    sys_duet2_aging_set_aging_status,
    NULL,
    NULL,
    NULL
};

sys_usw_mchip_nh_t sys_tsingma_mchip_nh =
{
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    _sys_usw_nh_ecmp_clear_dlb_flow,
};

sys_usw_mchip_misc_t sys_tsingma_mchip_misc =
{
     sys_tsingma_capability_init,
    NULL,
    sys_tm_map_drop_reason_sys_to_ctc,
    NULL,
    sys_duet2_register_get_glb_acl_table,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    sys_tm_get_drop_resson_info
};

sys_usw_mchip_paser_t sys_tsingma_mchip_psr =
{
    sys_tsingma_parser_set_hash_field,
    sys_tsingma_parser_get_hash_field,
    sys_tsingma_parser_hash_init,
    sys_tsingma_parser_set_global_cfg,
    sys_tsingma_parser_get_global_cfg
};


sys_usw_mchip_hash_t sys_tsingma_mchip_hash =
{
    sys_tsingma_hash_set_config,
    sys_tsingma_hash_get_config,
    sys_tsingma_hash_set_offset,
    sys_tsingma_hash_get_offset,
    sys_tsingma_hash_set_hash_control,
    sys_tsingma_hash_get_hash_control,
    NULL,   /* AT hash_init */
    NULL,   /* AT hash_set_selector_ext */
    NULL,   /* AT hash_get_selector_ext */
    NULL,   /* AT hash_set_selector_remap */
    NULL,   /* AT hash_get_selector_remap */
    NULL,   /* AT set_mask_profile_en */
    NULL,   /* AT set_udf_hash_en */
    NULL,   /* AT get_udf_hash_en */
    NULL,   /* AT set_field */
    NULL    /* AT get_field */
};

sys_usw_mchip_qos_t sys_tsingma_mchip_qos =
{
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    sys_usw_qos_api_cb_register_before_at,
    NULL,
    NULL  /*qos_fcdl_detect_mac*/
};

sys_usw_mchip_security_t sys_tsingma_mchip_security =
{
    NULL,
    NULL
};

sys_usw_mchip_diag_t sys_tsingma_mchip_diag =
{
#if (FEATURE_MODE == 0)
    sys_tsingma_diag_get_pkt_trace,
    sys_tsingma_diag_get_drop_info,
    sys_tsingma_diag_set_dbg_pkt,
    sys_tsingma_diag_set_dbg_session,
    NULL,
    NULL,
    sys_tsingma_diag_get_lb_hash,
    sys_tm_get_discard_type_desc,
    sys_tsingma_diag_get_pos,
    sys_tm_map_drop_reason_ctc_to_sys,
    sys_tm_diag_get_drop_reason
#endif
};

sys_usw_mchip_mon_t sys_tsingma_mchip_monitor =
{
#if (FEATURE_MODE == 0)
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    sys_tsingma_monitor_sync_data,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
#endif
};

sys_usw_mchip_flowstats_t sys_tsingma_mchip_flow_stats =
{
    _sys_usw_flow_stats_type_init,
    _sys_usw_flow_stats_ram_init,
    sys_duet2_flow_stats_show_status,
    sys_tsingma_flow_stats_ds2count,
    NULL
};

sys_usw_mchip_macstats_t sys_tsingma_mchip_mac_stats =
{
    NULL,
    NULL,
    NULL
};

sys_usw_mchip_npm_t sys_tsingma_mchip_npm =
{
    NULL,
    NULL
};
sys_usw_mchip_interrupt_t sys_tsingma_mchip_intr =
{
    sys_tsingma_interrupt_get_sup_info,
    sys_tsingma_interrupt_get_intrvec_offset,
    sys_tsingma_interrupt_db_init,
    sys_tsingma_interrpt_dispatch_func,
    NULL, /*interrupt_dispatch_flexe*/
    sys_tsingma_interrupt_isr_sup_normal,
    sys_tsingma_interrupt_init_reg,
    sys_tsingma_interrupt_set_sup_op
};

sys_usw_mchip_port_t sys_tsingma_mchip_port =
{
    NULL,
    NULL,
    NULL,
    NULL,
    sys_tsingma_port_set_property,
    sys_tsingma_port_get_property,
    sys_tsingma_port_init,
    NULL,
    NULL,
    NULL,
    NULL,
    sys_tsingma_port_set_xpipe_en,
    NULL
};
sys_usw_mchip_mirror_t sys_tsingma_mchip_mirror =
{
    NULL,
    NULL
};

sys_usw_mchip_packet_t sys_tsingma_mchip_packet =
{
    sys_tsingma_packet_txinfo_to_rawhdr,
    sys_tsingma_packet_rawhdr_to_rxinfo,
    sys_tsingma_packet_encap_array
};

sys_usw_mchip_oam_t sys_tsingma_mchip_oam =
{
#if  (FEATURE_MODE == 0)
    sys_dute2_oam_get_mep_info_for_event
#endif
};

sys_usw_mchip_xdata_t sys_tsingma_mchip_xdata =
{
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
};


sys_usw_mchip_srv6_t sys_tsingma_mchip_srv6 =
{
    NULL
};

sys_usw_mchip_aps_t sys_tsingma_mchip_aps =
{
#if (FEATURE_MODE == 0)
    NULL, /* AT aps_set_hw */
    NULL, /* AT aps_get_hw */
    NULL  /* AT aps_set_protections */
#endif
};

sys_usw_mchip_peri_t sys_tsingma_mchip_peri =
{
    sys_tsingma_peri_init,
    sys_tsingma_peri_mdio_init,
    sys_tsingma_peri_set_phy_scan_cfg,
    sys_tsingma_peri_set_phy_scan_para,
    sys_tsingma_peri_get_phy_scan_para,
    sys_tsingma_peri_read_phy_reg,
    sys_tsingma_peri_write_phy_reg,
    sys_tsingma_peri_set_mdio_clock,
    sys_tsingma_peri_get_mdio_clock,
    sys_tsingma_peri_set_mac_led_mode,
    sys_tsingma_peri_set_mac_led_mapping,
    sys_tsingma_peri_set_mac_led_en,
    sys_tsingma_peri_get_mac_led_en,
    sys_tsingma_peri_set_mac_led_clock,
    sys_tsingma_peri_get_mac_led_clock,
    sys_tsingma_peri_set_gpio_mode,
    sys_tsingma_peri_set_gpio_output,
    sys_tsingma_peri_get_gpio_input,
    sys_tsingma_peri_phy_link_change_isr,
    sys_tsingma_peri_get_chip_sensor,
    NULL,/* set sensor monitor */
    NULL,/* get sensor monitor */
    sys_tsingma_peri_set_phy_sample_offset,
    sys_tsingma_peri_get_phy_sample_offset,
    sys_tsingma_peri_set_phy_sample_edge,
    sys_tsingma_peri_get_phy_sample_edge
};

sys_usw_mchip_ptp_t sys_tsingma_mchip_ptp =
{

};

sys_usw_mchip_dmps_db_t sys_tsingma_mchip_dmps_db =
{
    sys_usw_dmps_get_port_property,
    sys_usw_dmps_get_lport_with_chan,
    sys_usw_dmps_get_lport_with_subchan_db,
    sys_usw_dmps_get_lport_with_mac,
    sys_dmps_get_sub_chan_by_chan,
};

sys_usw_mchip_sync_ether_t sys_tsingma_mchip_sync_ether =
{
    NULL, /* AT sync_ether_set_cfg */
    NULL  /* AT sync_ether_get_cfg */
};

sys_usw_mchip_dma_t sys_tsingma_mchip_dma =
{
    NULL,
    sys_tsingma_dma_tcam_scan_func,
    sys_duet2_dma_set_tcam_scan_mode,
    sys_tsingma_dma_sync_pkt_rx_stats,
    sys_tsingma_dma_sync_pkt_tx_stats,
    sys_tsingma_dma_pkt_tx,
    sys_tsingma_dma_pkt_rx,
    sys_tsingma_dma_set_pkt_timer,
    sys_tsingma_dma_set_session_pkt,
    sys_duet2_dma_function_pause,
    sys_tsingma_dma_sync_hash_dump,
    sys_tsingma_dma_set_packet_timer_cfg,
    NULL,
    NULL,
    sys_tsingma_dma_info_func,
    sys_tsingma_dma_stats_func,
    sys_tsingma_dma_pkt_tx_array,
    sys_tsingma_dma_read_table,
    sys_tsingma_dma_write_table,
    sys_tsingma_dma_reset
};

sys_usw_mchip_fdb_t sys_tsingma_mchip_fdb =
{
    NULL
};

sys_usw_mchip_serdes_t sys_tsingma_mchip_serdes = {NULL};

int32
sys_tsingma_mchip_init(uint8 lchip)
{

    p_sys_mchip_master[lchip]->p_capability = (uint32*)mem_malloc(MEM_SYSTEM_MODULE, sizeof(uint32)*SYS_CAP_MAX);
    if (NULL == p_sys_mchip_master[lchip]->p_capability)
    {
        return CTC_E_NO_MEMORY;
    }
    sal_memset(p_sys_mchip_master[lchip]->p_capability, 0, sizeof(uint32)*SYS_CAP_MAX);


    p_sys_mchip_master[lchip]->p_mchip_api = (sys_usw_mchip_api_t *)mem_malloc(MEM_SYSTEM_MODULE, sizeof(sys_usw_mchip_api_t));
    if (NULL == p_sys_mchip_master[lchip]->p_mchip_api)
    {
        return CTC_E_NO_MEMORY;
    }
    sal_memset(p_sys_mchip_master[lchip]->p_mchip_api, 0, sizeof(sys_usw_mchip_api_t));
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_1ae = &sys_tsingma_mchip_1ae;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_lag = &sys_tsingma_mchip_lag;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_dmps = &sys_tsingma_mchip_dmps;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_ipuc = &sys_tsingma_mchip_ipuc;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_acl = &sys_tsingma_mchip_acl;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_scl = &sys_tsingma_mchip_scl;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_l3if = &sys_tsingma_mchip_l3if;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_aging = &sys_tsingma_mchip_ag;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_nh = &sys_tsingma_mchip_nh;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_misc = &sys_tsingma_mchip_misc;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_paser = &sys_tsingma_mchip_psr;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_hash = &sys_tsingma_mchip_hash;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_qos = &sys_tsingma_mchip_qos;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_security = &sys_tsingma_mchip_security;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_diag = &sys_tsingma_mchip_diag;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_monitor = &sys_tsingma_mchip_monitor;
    p_sys_mchip_master[lchip]->p_mchip_api->p_flow_stats = &sys_tsingma_mchip_flow_stats;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mac_stats = &sys_tsingma_mchip_mac_stats;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_npm = &sys_tsingma_mchip_npm;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_intr = &sys_tsingma_mchip_intr;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_port = &sys_tsingma_mchip_port;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_ipfix = &sys_tsingma_mchip_ipfix;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_mirror= &sys_tsingma_mchip_mirror;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_packet= &sys_tsingma_mchip_packet;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_xdata = &sys_tsingma_mchip_xdata;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_oam= &sys_tsingma_mchip_oam;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_aps = &sys_tsingma_mchip_aps;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_flexe = &sys_tsingma_mchip_flexe;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_srv6 = &sys_tsingma_mchip_srv6;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_peri = &sys_tsingma_mchip_peri;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_ptp = &sys_tsingma_mchip_ptp;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_dmps_db = &sys_tsingma_mchip_dmps_db;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_sync_ether = &sys_tsingma_mchip_sync_ether;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_dma = &sys_tsingma_mchip_dma;
    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_fdb = &sys_tsingma_mchip_fdb;

    p_sys_mchip_master[lchip]->p_mchip_api->p_mchip_serdes = &sys_tsingma_mchip_serdes;
    sal_memset(p_sys_mchip_master[lchip]->feature,0x01,CTC_FEATURE_MAX*sizeof(uint8));
    p_sys_mchip_master[lchip]->feature[CTC_FEATURE_SRV6] = 0;
    p_sys_mchip_master[lchip]->feature[CTC_FEATURE_DTEL] = 0;
    p_sys_mchip_master[lchip]->feature[CTC_FEATURE_SC_OAM] = 0;
    p_sys_mchip_master[lchip]->feature[CTC_FEATURE_APP_VLAN_PORT] = 0;
    p_sys_mchip_master[lchip]->feature[CTC_FEATURE_FLEXE] = 0;
    p_sys_mchip_master[lchip]->feature[CTC_FEATURE_XDATA] = 0;
    p_sys_mchip_master[lchip]->sub_feature[SYS_FEATURE_HMAC] = 0;

    if(DRV_CHIP_SUB_TYPE_1 == DRV_CHIP_SUB_TYPE(lchip))
    {
        CTC_BIT_UNSET(p_sys_mchip_master[lchip]->feature[CTC_FEATURE_WLAN], 0);
        CTC_BIT_UNSET(p_sys_mchip_master[lchip]->feature[CTC_FEATURE_DOT1AE], 0);
    }
    return CTC_E_NONE;
}

int32
sys_tsingma_mchip_deinit(uint8 lchip)
{
    CTC_PTR_VALID_CHECK(p_sys_mchip_master[lchip]);

    if (p_sys_mchip_master[lchip]->p_capability)
    {
        mem_free(p_sys_mchip_master[lchip]->p_capability);
    }
    if (p_sys_mchip_master[lchip]->p_mchip_api)
    {
        mem_free(p_sys_mchip_master[lchip]->p_mchip_api);
    }
    return CTC_E_NONE;
}

#endif

